
class TarzanContactListener extends Box2D.Dynamics.b2ContactListener {
    private _scene: TarzanScene
    constructor(scene: TarzanScene) {
        super()
        this._scene = scene
    }

    public BeginContact(contact: Box2D.Dynamics.Contacts.b2Contact): void {
        let fixA = contact.GetFixtureA().GetBody().GetUserData() as PhyObject
        let fixB = contact.GetFixtureB().GetBody().GetUserData() as PhyObject
        if (fixA.Type == PhyObjectType.Player && fixB.Type == PhyObjectType.Terrian) {
            this.playContractTrrain(contact.GetFixtureA(), contact.GetFixtureB())
        } else if (fixA.Type == PhyObjectType.Terrian && fixB.Type == PhyObjectType.Player) {
            this.playContractTrrain(contact.GetFixtureB(), contact.GetFixtureA())
        }
    }
    public EndContact(contact: Box2D.Dynamics.Contacts.b2Contact): void {

    }
    public PostSolve(contact: Box2D.Dynamics.Contacts.b2Contact, impulse: Box2D.Dynamics.b2ContactImpulse): void {

    }
    public PreSolve(contact: Box2D.Dynamics.Contacts.b2Contact, oldManifold: Box2D.Collision.b2Manifold): void {
    }

    private playContractTrrain(fixP: Box2D.Dynamics.b2Fixture, fixT: Box2D.Dynamics.b2Fixture) {
        let player = fixP.GetBody().GetUserData() as PhyObject
        let trrain = fixT.GetBody().GetUserData() as PhyObject
        this._scene.GameOver()
    }
}